<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.laputa.service.model.MainFrameData"%>
<%@ page import="com.laputa.model.User"%>
<%@ page import="com.laputa.service.model.FriendListData"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'friendList.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <%
  	String userName = ((MainFrameData) session.getAttribute("userData")).getName();
  	List<User> friends = ((FriendListData) request.getAttribute("friendListData")).getUserList();
  	System.out.println("from friendlist, I have " + friends.size() + " friends.");
   %>
  
  <body>
    这是用户<%=userName%>的好友列表。<br>
    
    	<c:forEach var="i" items="<%=friends%>">
			<form method="post" action="friendList.do">
				<input type="hidden" name="userID" value="<%=((User)pageContext.findAttribute("i")).getId()%>"/>
				<input type="submit" name="showSingle" value="朋友${i}"/><br/>
			</form>
		</c:forEach>

	 <form method="post" action="login.do">
	 	<input type="submit" name="home" value="返回" />
	 </form>

  </body>
</html>
